package com.springcloudalibaba.apiAuth.configurer;

import com.springcloudalibaba.baseconfig.Intercept.AuthIntercept;
import com.springcloudalibaba.baseconfig.annotation.AuthMethodArgumentResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.List;

/**
 * @描述: TODO WebMvc配置
 * @作者: lixing lixing_java@163.com
 * @日期 2020/2/19 22:23
 */
@Component
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    /**
     * @描述 TODO 拦截器配置
     * @作者 lixing
     * @日期 2020/2/19 22:27
     * @Param [registry]
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 权限模块拦截器
        registry.addInterceptor(new AuthIntercept()).addPathPatterns("/**");
    }

    /**
     * @描述 TODO 参数解析器
     * @作者 李星
     * @日期 2020/2/20 13:34
     * @Param [resolvers]

     */
    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
        // 用户登录
        resolvers.add(new AuthMethodArgumentResolver());
    }
}
